package com.lms.logistics_management_system.controller;

import com.lms.logistics_management_system.common.Result;
import com.lms.logistics_management_system.controller.dto.*;
import com.lms.logistics_management_system.service.DoctorService;
import com.lms.logistics_management_system.service.ReservationService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Validated
@Controller
@RestController
@RequestMapping("/reservation")
public class ReservationController {
    @Autowired
    ReservationService reservationService;

    @Autowired
    DoctorService doctorService;

    @ApiOperation("添加或更改订单，对应检前客户预约接口")
//    @ApiImplicitParam(name="resdto", paramType = "query", example="",required = true)
    @PostMapping("/buyChangeReservation")
    public Result buyChangeReservation(@RequestBody ReservationDto resdto){
        return reservationService.buyChangeReservation(resdto);
    }


    @ApiOperation("检前团队预约接口")
//    @ApiImplicitParam(name="resdto", paramType = "query", example="",required = true)
    @PostMapping("/buyTeamReservation")
    public Result buyTeamReservation(@RequestBody TeamReservationDto teamReservationDto){
        return Result.success(reservationService.buyTeamReservation(teamReservationDto));
    }

    @ApiOperation("返回某用户所有的订单信息,为订单-项目列表及订单是否完成信息")
//    @ApiImplicitParam(name="openId", dataType = "string",paramType = "query", example="oGySO4rqHlUgQXce9tPqilkDs8N8",required = true)
    @PostMapping("/getAllResItemInfo")
    public Result getAllResItemInfo(@RequestParam String openId){
        return Result.success(reservationService.getAllResItemInfo(openId));
    }

    //---------以下对应检后-------
    @ApiOperation("检后报告查询")
    @GetMapping ("/getDiagnosticByReservationId")
    public Result getDiagnosticByReservationId(@RequestParam Integer reservationId){
        return Result.success(doctorService.getDiagnosticByReservationId(reservationId));
    }



//    {
//        "comboId": 0,
//            "reservationAppointmentTime": "2023-05-20",
//            "reservationBuyPrice": 200,
//            "reservationBuyTime": "2023-05-20T10:15:51.814Z",
//            "reservationId": 11,
//            "reservationIdNumber": "330905555555555556",
//            "reservationIsMarried": 0,
//            "reservationName": "我的预约1",
//            "reservationPhoneNumber": "52222222233",
//            "reservationSex": "男",
//            "teamReservationId": 0,
//            "userOpenid": "oGySO4rqHlUgQXce9tPqilkDs8N8"
//    }





//    @ApiOperation("某openid下 finished为1所有项目完成返回所有项目已完成得预约订单")
//    @PostMapping("/getClassfiedChangeReservation")
//    public Result getClassifyReservationByOpenid(@RequestParam String openId,@RequestParam Integer finished ) {
//        return Result.success(reservationService.getClassifiedReservationsByOpenid(openId,finished));
//    }

//    @ApiOperation("返回某个openId对应的所有项目,似乎没啥用")
//    @ApiImplicitParam(name="openId", dataType = "string",paramType = "query", example="oGySO4rqHlUgQXce9tPqilkDs8N8",required = true)
//    @PostMapping("/getReservationByOpenid")
//    public Result getReservationByOpenid(@RequestParam String openId) {
//        return Result.success(reservationService.getReservationByOpenid(openId));
//    }

//    @ApiOperation("删除预约")
//    @DeleteMapping("/getAllResinfo")
//    public Result DeleteReservation(){
//        return Result.success(reservationService.getAllResinfo());
//    }





    //------------------以下对应检中---------------------
    /**
     * 返回所有的科号对应的项目
     * @return
     * */
    @GetMapping("/list")
    public Result getAllItemList(){
        return Result.success(reservationService.getAllItemList());
    }

    /**
     * 添加项目到套餐内，对应检中已经购买过订单的客户
     * @param reservationId
     * @param itemId
     * @return 返回bool类型
     * */
    @ApiOperation("添加项目到套餐内，对应检中已经购买过订单的客户")
    @PostMapping("/addItemToReservation")
    public Result addItemToReservation(@RequestParam Integer reservationId,
                                       @RequestParam Integer itemId){
        return Result.success(reservationService.addItemToReservation(reservationId,itemId));
    }










}
